package cn.alm.springaihello.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import java.util.function.Function;

@Configuration
public class CalculatorConfig {

    public record addOperation(Integer a, Integer b) {
    }

    public record mulOperation(Integer a, Integer b) {
    }

    @Bean
    @Description("加法运算")
    // 第一个参数：方法名称
    // 第二个参数：返回值类型
    public Function<addOperation, Integer> addFunction() {
        return request -> {
            System.out.println("add function call");
            Integer result = request.a + request.b;
            return result;
        };
    }

    @Bean
    @Description("乘法运算")
    public Function<mulOperation, Integer> mulFunction() {
        return request -> {
            System.out.println("mul function call");
            Integer result = request.a * request.b;
            return result;
        };
    }
}
